<script>
	import tokenMatchApi from "api/tokenMatch.js"
	let userid = uni.getStorageSync('userid');
	export default {
		// 使用小程序生命周期
		async onLaunch() {
			// console.log('App Launch')
			let {
				data
			} = await tokenMatchApi()
			if (data.status == 200 && data.result && userid) {
				uni.redirectTo({
					url: "pages/index/index?id=" + userid
				})
			} else {
				uni.clearStorage()
				uni.showToast({
					title: "登入信息过期 请重新登入",
					icon: "none",
					duration: 1500,
					success() {
						setTimeout(() => {
							uni.redirectTo({
								url: "/pages/login/login"
							})
						}, 1500)
					}
				})

			}
		},
		onShow() {
			//用户进入前台后 进行链接
			this.$socket.connect()
			this.$socket.emit("registerUserid", userid)
		},
		onHide() {
			//用户退出后断开链接
			this.$socket.disconnect()
		},

		onLoad() {
			console.log("刷新");
		}

	}
</script>

<style>
	/*每个页面公共css */
</style>